<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""DTD/xhtml1-strict.dtd">
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="/WEB-INF/c.tld" prefix="c"%>
<%@taglib uri="/WEB-INF/fmt.tld" prefix="fmt"%>
<%@taglib uri="/WEB-INF/fn.tld" prefix="fn"%>
<%@taglib uri="/WEB-INF/el.tld" prefix="el"%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<c:import url="/includes/css_inc.jsp"/>
		<c:import url="/includes/js_inc.jsp"/>
		<script type="text/javaScript">
		
			$(function(){
				
	        	$("#btnSearch").button({
		            icons: {
		                primary: "ui-icon-search"
		            }
		        }).click(function(){
					if(validateEmpty()){
							$("#searchForm").submit();
					} else {
						return false;
					}
		        });
	        	
	        	
	        	$("#btnExport").button({
		            icons: {
		                primary: "ui-icon-arrowthickstop-1-s"
		            }
				}).click(function(){
					if(validateEmpty()){
						
			        		var provinceId =  $("#provinceId option:selected").val();			        		
			        		var startDate = $("#startDate").val();
			        		var endDate = $("#endDate").val();
			        		
			        		window.location='${pageContext.request.contextPath}/acc7?app=ACC70402&job=export&provinceId='+provinceId + '&startDate=' + startDate  +'&endDate='+endDate;
			        		
					}	
				});
	        	
		       // thaiDatepicker("startDate","#","1");
		        thaiDatepicker("endDate","#","1");
			});
			
		</script>
	</head>
	<body>
		<c:import url="/apps/msg.jsp"/>
		<form class="acc67-form" name="searchForm" id="searchForm" action="${pageContext.request.contextPath}/acc7" method="post">
		<input type="hidden" name="app" id="app" value="ACC70402"/>
		<input type="hidden" name="job" id="job" value="${job}"/>
			<table width="100%" class="ui-widget ui-widget-content" border="0">
				<tr>
					<th align="left" class="acc67-header ui-widget-header" colspan="2"><b>${screenCode.ACC70402}</b></th>
				</tr>
				<tr>
					<td class="bold">จังหวัด : </td>
					<td>
						<c:if test="${userInfo.areaLevel =='3'}">
							<c:forEach var="data" items="${userInfo.listUserProvice}">
								${data.provinceName}
								<input type="hidden" name="provinceId" id="provinceId" value="${data.provinceId}">
							</c:forEach>
						</c:if>
						<c:if test="${userInfo.areaLevel=='1' || userInfo.areaLevel=='2'}">
							<select name="provinceId" id="provinceId">
								<option value="">เลือกทั้งหมด</option>
								<c:forEach var="data" items="${userInfo.listUserProvice}">
									<c:if test="${data.provinceId == provinceId}" var="provinceSeleted"/>
									<option value="${data.provinceId}" ${provinceSeleted?'selected':''}>${data.provinceName}</option>
								</c:forEach>
							</select>
						</c:if>
					</td>
				</tr>
				<tr id="trDate">
					<td class="bold">วันที่ออกรายงาน : </td>
					<td>
						
<%-- 						<input type="text" name="startDate" id="startDate" size="12" maxlength="10" onkeypress="return numberAndSlash(event);" onblur="dateFormat(this);" value="${startDate}"/> --%>
						<input type="text" name="startDate" id="startDate" size="12" maxlength="10"  value="01/02/2556" readonly="readonly"/>
						<span id="#startDate" class="red">*</span>
						ถึงวันที่
						<input type="text" name="endDate" id="endDate" size="12" maxlength="10" onkeypress="return numberAndSlash(event);" onblur="dateFormat(this);" value="${endDate}"/>
						<span id="#endDate" class="red">*</span>
					</td>
				</tr>
			
				<tr>
					<td align="center" colspan="2">
						<button type="submit" name="btnSearch" id="btnSearch" class="acc67-button"> ค้นหาข้อมูล </button>
						<button type="button" name="btnExport" id="btnExport" class="acc67-button"> Download </button>
					</td>
				</tr>
			</table>
			
		<br/>
		
		<c:if test="${!empty pageBean.pageData}">
			<fieldset>
				<legend> ผลการค้นหา </legend>
					<table width="100%" class="ui-widget ui-widget-content" border="0">
						<tr>
							<th align="center" class="ui-state-default" width="8%"></span>รหัสเขต</th>
							<th align="center" class="ui-state-default" width="15%"></span>เขต</th>
							<th align="center" class="ui-state-default" width="8%">รหัสจังหวัด</th>
							<th align="center" class="ui-state-default" width="10%">จังหวัด</th>
							<th align="center" class="ui-state-default" >ยกมา</th>
							<th align="center" class="ui-state-default">รับโอนSAP</th>
							<th align="center" class="ui-state-default">รายรับ</th>
							<th align="center" class="ui-state-default">รายจ่าย</th>
							<th align="center" class="ui-state-default">คงเหลือ</th>
						</tr>
						<c:forEach items="${pageBean.pageData}" var="data" varStatus="x">
							<tr class="grid-tr-${x.count % 2}">
								<td>${data.NHSO_ZONE}</td>
								<td>${data.NHSO_ZONENAME}</td>
								<td>${data.PROVINCE_ID}</td>
								<td>${data.PROVINCE_NAME}</td>
								<td align="right">
									<fmt:formatNumber pattern="#,##0.00" value="${data.TYPE_B}"/>
								</td>
								<td align="right">
									<fmt:formatNumber pattern="#,##0.00" value="${data.TYPE_S}"/>
								</td>
								<td align="right">
									<fmt:formatNumber pattern="#,##0.00" value="${data.TYPE_I}"/>
								</td>
								<td align="right">
									<fmt:formatNumber pattern="#,##0.00" value="${data.TYPE_E}"/>
								</td>
								
								<td align="right">
									<fmt:formatNumber pattern="#,##0.00" value="${(data.TYPE_B+data.TYPE_S+data.TYPE_I) - data.TYPE_E}"/>
								</td>
							</tr>
						</c:forEach>
						<input type="hidden" name="formPage" id="formPage" value="searchForm"/>
						<c:import url="/apps/page.jsp"/>
					</table>
			</fieldset>
		</c:if>
		</form>
	</body>
</html>